#pragma once
#include "ICamera.h"
#include "BlockRenderer.h"
#include "BlockLibrary.h"
#include "BlockRenderer.h"
#include "TypeDefs.h"
#include "IGameScreen.h"
#include "ChunkManager.h"
#include "Entity.h"
#include "Player.h"
//#include "PerlinNoiseMap.h"
#include <boost/shared_ptr.hpp>

#define MAP_INDEX(__x,__z) ((32*(__z))+(__x))
class World
{
public:
	World(void);
	~World(void);
	int Initialize(IGameScreen *pOwner, BlockLibrary *pBlockLibrary, BlockRenderer *pBlockRenderer, uint terrainTexture);
	void Update();
	void Draw();
	Player *GetPlayerEntity() { return &m_playerEntity; };
public:
	int Generate(int seed);
	void DrawTerrainGrid(vector2 start, float step, int stepCount);

private:
	BlockLibrary *m_pBlockLibrary;
	BlockRenderer *m_pBlockRenderer;
	IRenderer *m_pRenderer;
	IGameScreen *m_pOwnerScreen;
	Player m_playerEntity;

	Texture m_noiseTex;

	ChunkManager m_chunkManager;
	uint m_nTerrainTexture;
	int m_nSeed;
	float *m_pTMap;

};

//Scrappy terrain generation code
	/*
protected: // Generator Functions
	uint HeightFunction(vector2 m_position);
protected:
	void DrawTestTerrain(float *pTerrain, int dimension);
	void AverageSquare(uint i, uint j, int *pTerrain, int nStride, int dimension);
	void AverageDiamond(uint i, uint j, int *pTerrain, int nStride, int dimension);
	void AverageSquare(uint i, uint j, float *pTerrain, int nStride, int dimension);
	void AverageDiamond(uint i, uint j, float *pTerrain, int nStride, int dimension);
	void GenerateHeightMap(int dimension, int *pTerrain, float h);
	void GenerateHeightMap(int dimension, float *pTerrain, float h);
private:
	uint m_nTDim;
	float *m_pTestTerrain2;
	uint *m_pBlockHeight;

	//Random number generation
	RandomGenerator m_randomGenerator;
	RandomDistributor m_distributor;
	RandomRealDistributor m_floatDistributor;
	*/


